public class Person {
    private int age;
    public void setAge(int age) {
        if (age >= 0 && age <= 120) {
            this.age = age;
            System.out.println("年龄为: " + this.age);
        } else {
            System.out.println(" 年龄必须是0到120之间");
        }
    }
    public int getAge() {
        return age;
    }
    public static void main(String[] args) {
        Person person = new Person();
        person.setAge(30);
        System.out.println("输入人的年龄: " + person.getAge());
        person.setAge(150);
        System.out.println("输入后的年龄: " + person.getAge());
    }
}